Skip to content

chore: git tag - fixing contracts for pretag#39581

Merged
brayn003 merged 15 commits intoreleasefrom
chore/git-tag-3
Mar 14, 2025
Merged

chore: git tag - fixing contracts for pretag#39581
brayn003 merged 15 commits intoreleasefrom
chore/git-tag-3

Conversation

@brayn003
Copy link
Contributor

@brayn003 brayn003 commented Mar 5, 2025

Description

  • Updates api contracts for pretag validation in release tab

Fixes #38808

Automation

/ok-to-test tags="@tag.Git"

🔍 Cypress test results

Tip

🟢 🟢 🟢 All cypress tests have passed! 🎉 🎉 🎉
Workflow run: https://github.com/appsmithorg/appsmith/actions/runs/13821575387
Commit: 751c6ee
Cypress dashboard.
Tags: @tag.Git
Spec:


Wed, 12 Mar 2025 22:04:53 UTC

Communication

Should the DevRel and Marketing teams inform users about this change?

  • Yes
  • No

Summary by CodeRabbit

  • New Features

    • Introduced a new TabRelease component for managing pre-tagging functionality.
    • Added a custom hook usePretag for improved data management related to pre-tagging.
    • Implemented a new useReleaseTag hook for handling release tag creation.
    • Enhanced OpsModalView to conditionally render tagging capabilities based on artifact definition.
    • Added a new isGitTaggingEnabled function to determine if tagging is applicable based on artifact type.
    • Introduced loading states and improved commit information display in LatestCommitInfoView.
  • Bug Fixes

    • Updated components to utilize the new pre-tagging data structure, ensuring accurate information is displayed.
    • Improved display logic in LatestCommitInfoView for commit messages and author information.
  • Refactor

    • Removed outdated commit-related actions and state management, transitioning to pre-tagging actions and state.
    • Modified selectors to focus on pre-tagging data instead of the latest commit state.
    • Renamed and restructured components for clarity and consistency in handling pre-tagging and release tagging.
  • Style

    • Updated the TAB_RELEASE property for improved display consistency.
    • Added new constants for loading and no commit messages to enhance user feedback.

@brayn003 brayn003 self-assigned this Mar 5, 2025
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Mar 5, 2025

Walkthrough

This pull request migrates commit data fetching from the old "latestCommit" mechanism to a new "pretag" system. It updates multiple React components to use the usePretag hook, renames and refactors components (e.g., TabRelease to TabReleaseView), and adjusts Redux actions, slices, selectors, and TypeScript types accordingly. Deprecated files and types related to the previous hook are removed, while new actions, request signatures, and types for handling pretag data are introduced.

Changes

File(s) Change Summary
app/client/src/git/components/LatestCommitInfo/index.tsx
app/client/src/git/components/ReleaseVersionRadioGroup/index.tsx
Replaced hook usage from useLatestCommit to usePretag and updated variable references (e.g., latestCommitpretagResponse).
app/client/src/git/components/OpsModal/TabRelease/TabReleaseView.tsx
app/client/src/git/components/OpsModal/TabRelease/index.tsx
Renamed component to TabReleaseView; introduced new TabReleaseProps with a fetchPretag prop; added a lifecycle hook to call fetchPretag and wrapped with a new TabRelease component connecting to usePretag.
app/client/src/git/hooks/useLatestCommit.ts Deleted obsolete hook for fetching commit data.
app/client/src/git/hooks/usePretag.ts Added a new hook to manage pretag data using Git context and Redux dispatch.
app/client/src/git/requests/fetchLatestCommitRequest.types.ts Removed outdated type definitions for latest commit responses.
app/client/src/git/requests/pretagRequest.ts
app/client/src/git/requests/pretagRequest.types.ts
Updated the exported function to pretagRequest with a new response type (PretagResponse); added new type definitions for pretag responses.
app/client/src/git/store/actions/fetchLatestCommitActions.ts Removed old commit actions and associated TypeScript types.
app/client/src/git/store/actions/pretagActions.ts Introduced new actions: pretagInitAction, pretagSuccessAction, and pretagErrorAction for handling pretag operations.
app/client/src/git/store/gitArtifactSlice.ts
app/client/src/git/store/helpers/initialState.ts
app/client/src/git/store/selectors/gitArtifactSelectors.ts
app/client/src/git/store/types.ts
Updated Redux slice, initial state, selectors, and types to replace commit-related state with pretag state.

Sequence Diagram(s)

sequenceDiagram
    participant C as TabRelease Component
    participant H as usePretag Hook
    participant A as Redux Actions
    participant API as pretagRequest API
    participant S as Redux Store

    C->>H: Invoke fetchPretag (via useEffect)
    H->>A: Dispatch pretagInitAction
    A->>API: Call pretagRequest()
    API-->>A: Return PretagResponse
    A->>S: Dispatch pretagSuccessAction with response
    S-->>H: Update pretag state
Loading

Possibly related PRs

  • chore: git tag - ui components for tagging release #39508: The changes in the main PR are related to the modifications in the LatestCommitInfo component, which is also referenced in the retrieved PR, specifically in the context of displaying commit information. Both PRs involve updates to how commit data is handled and presented in the UI.

Suggested labels

Bug, Medium, Needs Triaging

Suggested reviewers

  • ApekshaBhosale
  • AnaghHegde
  • ashit-rath

Poem

In our code a change does gleam,
From "latestCommit" to a "pretag" dream.
Components awaken with a fresh new call,
Redux and hooks now answer the call.
CodeRabbit cheers with a joyful beat,
As our Git flow dances neat! 🎉


📜 Recent review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro (Legacy)

📥 Commits

Reviewing files that changed from the base of the PR and between e2e1ee0 and 751c6ee.

📒 Files selected for processing (2)
  • app/client/src/git/components/LatestCommitInfo/LatestCommitInfoView.test.tsx (1 hunks)
  • app/client/src/git/components/ReleaseVersionRadioGroup/ReleaseVersionRadioGroupView.test.tsx (3 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • app/client/src/git/components/ReleaseVersionRadioGroup/ReleaseVersionRadioGroupView.test.tsx
⏰ Context from checks skipped due to timeout of 90000ms (8)
  • GitHub Check: perform-test / rts-build / build
  • GitHub Check: perform-test / client-build / client-build
  • GitHub Check: perform-test / server-build / server-unit-tests
  • GitHub Check: client-unit-tests / client-unit-tests
  • GitHub Check: client-prettier / prettier-check
  • GitHub Check: client-lint / client-lint
  • GitHub Check: client-check-cyclic-deps / check-cyclic-dependencies
  • GitHub Check: client-build / client-build
🔇 Additional comments (8)
app/client/src/git/components/LatestCommitInfo/LatestCommitInfoView.test.tsx (8)

7-8: Improved test stability with dynamic timestamp calculation.

Using a relative timestamp (1 hour ago) instead of a hardcoded date ensures the tests are more maintainable and less likely to fail over time.


10-28: Good test refactoring using test ids.

Switching from text-based queries to test ID-based queries is a better testing practice. This approach is less brittle and provides more reliable test coverage.


32-47: Properly testing null authorName scenario.

The test correctly verifies that the author information is not displayed when authorName is null, while ensuring other elements still render properly.


50-66: Correct handling of null committedAt case.

This test appropriately checks that when the timestamp is null, only the author's name is displayed without time information.


69-86: Good fallback handling for null hash.

Test correctly verifies that a dash is displayed when the hash is null, which is a good UX practice.


89-108: Properly testing fallback message for null commits.

Test validates that the appropriate fallback message is shown when no commit message is available.


111-129: Comprehensive test for the edge case with all null props.

This test ensures the component properly handles the scenario when all data is missing, displaying appropriate fallbacks.


131-145: Good addition of loading state test.

The new test for loading state ensures that users get appropriate feedback when commit data is being fetched, improving the user experience.


🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@github-actions github-actions bot added Git Product Issues related to version control product Packages & Git Pod All issues belonging to Packages and Git Task A simple Todo labels Mar 5, 2025
@brayn003 brayn003 requested a review from ashit-rath March 5, 2025 16:34
@brayn003 brayn003 added the ok-to-test Required label for CI label Mar 5, 2025
@github-actions github-actions bot added the skip-changelog Adding this label to a PR prevents it from being listed in the changelog label Mar 5, 2025
@brayn003 brayn003 changed the title chore: fixing contracts for pretag chore: git tag - fixing contracts for pretag Mar 5, 2025
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🧹 Nitpick comments (2)
app/client/src/git/components/LatestCommitInfo/index.tsx (1)

10-13: Property access paths updated for new structure.

All property access paths have been correctly updated to match the new pretagResponse structure. Consider adding extra null check for the author property.

-      authorName={pretagResponse?.author.name ?? null}
+      authorName={pretagResponse?.author?.name ?? null}
app/client/src/git/requests/pretagRequest.types.ts (1)

3-15: Interface structure is well-defined.

The PretagResponseData interface clearly defines the expected structure of the pretag response data. Consider adding JSDoc comments for better documentation.

+/**
+ * Represents the data structure of a pretag response
+ */
 export interface PretagResponseData {
+  /**
+   * Author information of the commit
+   */
   author: {
     name: string;
     email: string;
   };
+  /**
+   * ISO timestamp of when the commit was made
+   */
   committedAt: string;
+  /**
+   * Commit hash identifier
+   */
   hash: string;
+  /**
+   * Commit message
+   */
   message: string;

+  /**
+   * Name of the release tag
+   */
   releaseTagName: string;
+  /**
+   * ISO timestamp of when the release was created
+   */
   releasedAt: string;
+  /**
+   * Indicates if the commit can be released
+   */
   isReleasable: boolean;
 }
📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between a619db5 and c0ed0fa.

📒 Files selected for processing (15)
  • app/client/src/git/components/LatestCommitInfo/index.tsx (1 hunks)
  • app/client/src/git/components/OpsModal/TabRelease/TabReleaseView.tsx (3 hunks)
  • app/client/src/git/components/OpsModal/TabRelease/index.tsx (1 hunks)
  • app/client/src/git/components/ReleaseVersionRadioGroup/index.tsx (2 hunks)
  • app/client/src/git/hooks/useLatestCommit.ts (0 hunks)
  • app/client/src/git/hooks/usePretag.ts (1 hunks)
  • app/client/src/git/requests/fetchLatestCommitRequest.types.ts (0 hunks)
  • app/client/src/git/requests/pretagRequest.ts (1 hunks)
  • app/client/src/git/requests/pretagRequest.types.ts (1 hunks)
  • app/client/src/git/store/actions/fetchLatestCommitActions.ts (0 hunks)
  • app/client/src/git/store/actions/pretagActions.ts (1 hunks)
  • app/client/src/git/store/gitArtifactSlice.ts (2 hunks)
  • app/client/src/git/store/helpers/initialState.ts (1 hunks)
  • app/client/src/git/store/selectors/gitArtifactSelectors.ts (1 hunks)
  • app/client/src/git/store/types.ts (2 hunks)
💤 Files with no reviewable changes (3)
  • app/client/src/git/requests/fetchLatestCommitRequest.types.ts
  • app/client/src/git/hooks/useLatestCommit.ts
  • app/client/src/git/store/actions/fetchLatestCommitActions.ts
⏰ Context from checks skipped due to timeout of 90000ms (9)
  • GitHub Check: build
  • GitHub Check: perform-test / rts-build / build
  • GitHub Check: perform-test / server-build / server-unit-tests
  • GitHub Check: perform-test / client-build / client-build
  • GitHub Check: client-check-cyclic-deps / check-cyclic-dependencies
  • GitHub Check: client-unit-tests / client-unit-tests
  • GitHub Check: client-prettier / prettier-check
  • GitHub Check: client-build / client-build
  • GitHub Check: client-lint / client-lint
🔇 Additional comments (26)
app/client/src/git/hooks/usePretag.ts (5)

1-7: Imports are correctly organized.

The imports are well-structured and include all necessary dependencies for the hook functionality.


8-12: Well-structured hook with proper context extraction.

The hook correctly uses the Git context to extract necessary artifact information.


13-14: State selection implemented correctly.

The hook properly uses the selector to retrieve the pretag state from the Redux store.


15-19: Memoized callback with appropriate dependencies.

The fetchPretag function is correctly memoized with useCallback and includes all the necessary dependencies in the dependency array.


21-26: Return object handles null cases properly.

The return object correctly uses the null coalescing operator to provide fallback values when the state properties are undefined.

app/client/src/git/components/OpsModal/TabRelease/index.tsx (3)

1-4: Imports are correctly structured.

The component imports all necessary dependencies including the new usePretag hook.


5-9: Component implementation is concise and focused.

The component has a single responsibility - to connect the pretag functionality to the view component.


11-12: Export is properly defined.

The default export makes the component available for import in other modules.

app/client/src/git/components/LatestCommitInfo/index.tsx (2)

3-3: Import updated to use the new hook.

Correctly updated to use usePretag instead of the previous useLatestCommit hook.


6-6: Destructuring updated for new data structure.

Correctly updated to extract pretagResponse instead of latestCommit.

app/client/src/git/requests/pretagRequest.types.ts (2)

1-2: Import is correctly defined.

The ApiResponse type import is appropriately included.


17-17: Type alias is correctly defined.

The PretagResponse type correctly extends the ApiResponse type with the PretagResponseData interface.

app/client/src/git/components/ReleaseVersionRadioGroup/index.tsx (1)

4-4: Hook migration implementation is correct.

The migration from useLatestCommit to usePretag is properly implemented with appropriate property access updates (releaseTagName, releasedAt). Proper optional chaining and nullish coalescing are used to handle potential undefined values.

Also applies to: 13-13, 17-17, 19-19

app/client/src/git/store/helpers/initialState.ts (1)

132-136: New pretag state initialization looks good.

The new pretag property is correctly added to the state with the standard structure (value, loading, error) and appropriate initial values.

app/client/src/git/components/OpsModal/TabRelease/TabReleaseView.tsx (4)

6-7: Props interface properly defined.

The TabReleaseProps interface is well-defined with the appropriate function signature for fetchPretag.

Also applies to: 25-27


29-29: Renamed component with proper prop destructuring.

The component has been correctly renamed from TabRelease to TabReleaseView with default value handling using noop.


35-40: Appropriate effect hook implementation.

The useEffect is correctly implemented with a descriptive name and proper dependency array to ensure fetchPretag is called on component mount and when the function reference changes.


72-72: Export statement updated correctly.

Export statement properly reflects the new component name.

app/client/src/git/requests/pretagRequest.ts (1)

4-4:

Details

❓ Verification inconclusive

API request function renamed but endpoint unchanged.

The function has been appropriately renamed from fetchLatestCommitRequest to pretagRequest with updated return type. Note that the API endpoint still contains "commit/latest" in the URL - ensure this is aligned with backend expectations.

Also applies to: 8-11


🏁 Script executed:

#!/bin/bash
# Check if there are any references to the endpoint in other files that might need updating
rg -A 2 "commit/latest" --glob "*.{ts,tsx}" | grep -v "pretagRequest.ts"

Length of output: 70


Endpoint Verification: Please confirm backend alignment

The function has been successfully renamed to pretagRequest with the updated return type, but the API URL still includes "commit/latest" (notably around lines 8–11 of app/client/src/git/requests/pretagRequest.ts). Our initial search didn’t reveal other usages of this endpoint, so please manually verify that the backend still expects "commit/latest" for this API call.

  • File: app/client/src/git/requests/pretagRequest.ts (especially lines 8–11)
  • Action: Confirm with backend or update the endpoint as needed to match backend expectations
app/client/src/git/store/selectors/gitArtifactSelectors.ts (1)

91-94: Selector implementation looks good.

New selector correctly retrieves the pretag state from API responses.

app/client/src/git/store/types.ts (2)

22-22: Import statement correctly added.

The new import for PretagResponseData replaces the removed FetchLatestCommitResponseData import.


63-63: Type definition properly updated.

The new pretag property replaces the removed latestCommit property in GitArtifactAPIResponsesReduxState.

app/client/src/git/store/gitArtifactSlice.ts (2)

145-148: Imports correctly updated.

New pretag action imports replace the removed latestCommit actions.


213-215: Reducers properly defined.

New pretag reducers added to replace the removed latestCommit reducers.

app/client/src/git/store/actions/pretagActions.ts (2)

20-27: Success action implementation looks good.

The success action correctly updates the state with the pretag response data.


29-38: Error action implementation is correct.

The error handling is properly implemented to update the state with error information.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🧹 Nitpick comments (3)
app/client/src/git/hooks/useReleaseTag.ts (1)

8-36: Well-structured hook implementation

The hook follows React best practices by using useCallback for memoization and properly setting up dependencies. It handles the release tag creation workflow cleanly.

Consider adding explicit TypeScript return type annotation for this hook to improve type safety and developer experience:

-function useReleaseTag() {
+function useReleaseTag(): {
+  isCreateReleaseTagLoading: boolean;
+  createReleaseTagError: Error | null;
+  createReleaseTag: (params: { tag: string; releaseNote: string; commitSHA: string }) => void;
+} {
app/client/src/git/components/OpsModal/OpsModalView.tsx (1)

63-78: Consider adding analytics logging for the Release tab.

The handleTabKeyChange function logs analytics events for Deploy and Merge tabs, but there's no equivalent logging for the new Release tab. For consistency, consider adding analytics for the Release tab.

if (tabKey === GitOpsTab.Deploy) {
  AnalyticsUtil.logEvent("GS_DEPLOY_GIT_MODAL_TRIGGERED", {
    source: `${tabKey.toUpperCase()}_TAB`,
  });
} else if (tabKey === GitOpsTab.Merge) {
  AnalyticsUtil.logEvent("GS_MERGE_GIT_MODAL_TRIGGERED", {
    source: `${tabKey.toUpperCase()}_TAB`,
  });
+} else if (tabKey === GitOpsTab.Release) {
+  AnalyticsUtil.logEvent("GS_RELEASE_GIT_MODAL_TRIGGERED", {
+    source: `${tabKey.toUpperCase()}_TAB`,
+  });
}
app/client/src/git/components/LatestCommitInfo/LatestCommitInfoView.tsx (1)

28-31: Improve conditional rendering logic for better readability.

The current implementation uses multiple conditional renders which makes the code harder to read. Consider using a more concise approach:

- {authorName && !committedAt ? `Committed by ${authorName}` : null}
- {authorName && committedAt
-   ? `${authorName} committed ${committedAt ?? "-"}`
-   : null}
+ {authorName ? (
+   committedAt 
+     ? `${authorName} committed ${committedAt}` 
+     : `Committed by ${authorName}`
+ ) : null}

This approach consolidates the logic and makes it more maintainable.

📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro (Legacy)

📥 Commits

Reviewing files that changed from the base of the PR and between 4e8ddf6 and 76266a9.

📒 Files selected for processing (18)
  • app/client/src/git/ce/constants/messages.tsx (1 hunks)
  • app/client/src/git/components/LatestCommitInfo/LatestCommitInfoView.tsx (1 hunks)
  • app/client/src/git/components/LatestCommitInfo/index.tsx (1 hunks)
  • app/client/src/git/components/OpsModal/OpsModalView.tsx (4 hunks)
  • app/client/src/git/components/OpsModal/TabRelease/TabReleaseView.tsx (4 hunks)
  • app/client/src/git/components/OpsModal/TabRelease/index.tsx (1 hunks)
  • app/client/src/git/components/OpsModal/index.tsx (2 hunks)
  • app/client/src/git/components/ReleaseVersionRadioGroup/ReleaseVersionRadioGroupView.tsx (2 hunks)
  • app/client/src/git/components/ReleaseVersionRadioGroup/index.tsx (2 hunks)
  • app/client/src/git/helpers/isGitTaggingEnabled.ts (1 hunks)
  • app/client/src/git/hooks/useReleaseTag.ts (1 hunks)
  • app/client/src/git/requests/pretagRequest.ts (1 hunks)
  • app/client/src/git/sagas/index.ts (2 hunks)
  • app/client/src/git/sagas/pretagSaga.ts (1 hunks)
  • app/client/src/git/store/actions/createReleaseTagActions.ts (1 hunks)
  • app/client/src/git/store/gitArtifactSlice.ts (2 hunks)
  • app/client/src/git/store/selectors/gitArtifactSelectors.ts (1 hunks)
  • app/client/src/git/store/types.ts (2 hunks)
✅ Files skipped from review due to trivial changes (1)
  • app/client/src/git/ce/constants/messages.tsx
🚧 Files skipped from review as they are similar to previous changes (6)
  • app/client/src/git/components/LatestCommitInfo/index.tsx
  • app/client/src/git/components/OpsModal/TabRelease/index.tsx
  • app/client/src/git/store/types.ts
  • app/client/src/git/components/ReleaseVersionRadioGroup/index.tsx
  • app/client/src/git/store/selectors/gitArtifactSelectors.ts
  • app/client/src/git/store/gitArtifactSlice.ts
⏰ Context from checks skipped due to timeout of 90000ms (8)
  • GitHub Check: perform-test / client-build / client-build
  • GitHub Check: perform-test / server-build / server-unit-tests
  • GitHub Check: perform-test / rts-build / build
  • GitHub Check: client-lint / client-lint
  • GitHub Check: client-check-cyclic-deps / check-cyclic-dependencies
  • GitHub Check: client-build / client-build
  • GitHub Check: client-unit-tests / client-unit-tests
  • GitHub Check: client-prettier / prettier-check
🔇 Additional comments (27)
app/client/src/git/helpers/isGitTaggingEnabled.ts (1)

4-10: Clean and straightforward implementation

The function correctly checks if Git tagging is enabled based on the artifact type.

The function could be simplified to a one-liner, but the current implementation with explicit control flow is clear and maintainable.

app/client/src/git/sagas/index.ts (2)

44-44: Correctly added new saga import

The pretagSaga import follows the existing pattern in the file.


90-92: Proper integration of pretagSaga

The pretag functionality is correctly integrated into the blocking action sagas, maintaining consistency with the application's saga architecture.

app/client/src/git/components/OpsModal/index.tsx (3)

8-8: Added GitContext integration

Appropriate import for accessing the Git context.


11-11: Correctly extracts artifactDef from context

The component now uses the Git context to access the artifact definition.


22-22: Properly passes artifactDef to child component

The artifactDef is correctly passed down to OpsModalView, enabling conditional rendering of the tagging functionality.

app/client/src/git/components/OpsModal/OpsModalView.tsx (3)

52-53: LGTM! Clean implementation of the conditional logic.

The implementation correctly checks if tagging is enabled based on the provided artifact definition.


102-110: LGTM! Well-structured conditional tab rendering.

The conditional rendering of the Release tab is properly implemented with appropriate data-testid attributes.


115-117: LGTM! Proper conditional component rendering.

The TabRelease component is correctly rendered only when tagging is enabled and the corresponding tab is selected.

app/client/src/git/requests/pretagRequest.ts (3)

4-4: LGTM! Correct type import.

The import statement correctly references the new PretagResponse type.


8-11: LGTM! Function signature properly updated.

The function has been appropriately renamed from fetchLatestCommitRequest to pretagRequest with the correct return type.


13-13: LGTM! API endpoint updated correctly.

The API endpoint has been updated from "commit/latest" to "pretag" to match the new functionality.

app/client/src/git/components/LatestCommitInfo/LatestCommitInfoView.tsx (1)

26-26: LGTM! Good use of nullish coalescing.

The nullish coalescing operator provides a sensible default when message is null.

app/client/src/git/sagas/pretagSaga.ts (2)

1-9: LGTM! Well-organized imports.

The imports are logically organized and include all necessary dependencies for the saga.


10-36: LGTM! Well-structured saga implementation.

The saga follows the standard pattern:

  1. Extracts data from the action payload
  2. Makes the API call
  3. Validates the response
  4. Dispatches success or error actions accordingly
  5. Includes proper error handling

The structure is clear, and the error handling is comprehensive.

app/client/src/git/components/OpsModal/TabRelease/TabReleaseView.tsx (5)

25-34: Well-defined interface with clear property types

The TabReleaseProps interface clearly defines the contract for this component with appropriate types for each property.


36-41: Good use of default values for props

Using default values like noop for functions and false/null for primitive values prevents runtime errors when props are not provided.


47-52: Proper effect implementation with named function and dependency array

The useEffect hook follows best practices by using a named function and correctly listing dependencies.


54-60: Callback handles null values correctly

Good use of nullish coalescing operators to handle potential null values safely.


80-80: Loading state implementation in UI

Properly connecting the loading state to the button's isLoading prop improves user feedback.

app/client/src/git/components/ReleaseVersionRadioGroup/ReleaseVersionRadioGroupView.tsx (3)

10-10: Improved naming for better semantic clarity

Changing from currentVersion to latestReleaseVersion provides better semantic clarity about the purpose of this prop.


23-26: Simplified version calculation logic

The version calculation logic has been streamlined to only check for releaseType, with proper fallback to "0.0.0" when latestReleaseVersion is null. Dependencies are correctly updated in the dependency array.


65-74: Improved conditional rendering

The conditional rendering now checks for latestReleaseVersion and displays version information with appropriate formatting.

app/client/src/git/store/actions/createReleaseTagActions.ts (4)

4-9: Well-structured payload interface

The CreateReleaseTagInitPayload interface properly defines all the required properties with clear names.


11-17: Clean implementation of initialization action

The initialization action correctly sets loading state and clears previous errors.


19-23: Concise success action

The success action does exactly what's needed - sets loading to false.


25-33: Complete error handling

The error action properly extracts the error from the payload and updates the state accordingly.


const handleClickOnRelease = useCallback(() => {
createReleaseTag({
tag: releaseVersion ?? "",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we check for the presence of releaseVersion and then only dispatch this action?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But that would silently fail without an error :(
Will be hard to debug

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can throw an error but would making this call with empty releaseVersion would also throw an error then we are fine but throwing error early would be pre-emptive

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The api will throw an error in this case
Also, the button is disabled when these values are not available. So, I don't think this case will ever get realised.
Had to add nullish coalescing because typescript

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🧹 Nitpick comments (2)
app/client/src/git/components/ReleaseVersionRadioGroup/ReleaseVersionRadioGroupView.tsx (2)

27-36: Enhance code clarity with a comment about version prefix handling.

The version calculation logic looks correct, but lacks context about why slice(1) is used.

    const latestReleaseVersionVal = latestReleaseVersion
+     // Remove the 'v' prefix from the version string for semver operations
      ? latestReleaseVersion.slice(1)
      : "0.0.0";

75-85: Simplify conditional text display with optional chaining.

Line 82 contains a redundant null check since we're already inside a conditional block that ensures latestReleaseVersion exists.

    {RELEASE_VERSION_RADIO_GROUP.LAST_RELEASED}:{" "}
-   {latestReleaseVersion ?? "-"}{" "}
+   {latestReleaseVersion}{" "}
    {readableReleaseAt ? `(${readableReleaseAt} ago)` : null}
📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro (Legacy)

📥 Commits

Reviewing files that changed from the base of the PR and between 277c7f9 and e2e1ee0.

📒 Files selected for processing (7)
  • app/client/src/git/ce/constants/messages.tsx (2 hunks)
  • app/client/src/git/components/LatestCommitInfo/LatestCommitInfoView.test.tsx (1 hunks)
  • app/client/src/git/components/LatestCommitInfo/LatestCommitInfoView.tsx (2 hunks)
  • app/client/src/git/components/LatestCommitInfo/index.tsx (1 hunks)
  • app/client/src/git/components/ReleaseVersionRadioGroup/ReleaseVersionRadioGroupView.test.tsx (3 hunks)
  • app/client/src/git/components/ReleaseVersionRadioGroup/ReleaseVersionRadioGroupView.tsx (2 hunks)
  • app/client/src/git/requests/pretagRequest.types.ts (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (4)
  • app/client/src/git/components/LatestCommitInfo/index.tsx
  • app/client/src/git/components/ReleaseVersionRadioGroup/ReleaseVersionRadioGroupView.test.tsx
  • app/client/src/git/components/LatestCommitInfo/LatestCommitInfoView.tsx
  • app/client/src/git/requests/pretagRequest.types.ts
⏰ Context from checks skipped due to timeout of 90000ms (8)
  • GitHub Check: perform-test / client-build / client-build
  • GitHub Check: perform-test / rts-build / build
  • GitHub Check: perform-test / server-build / server-unit-tests
  • GitHub Check: client-unit-tests / client-unit-tests
  • GitHub Check: client-lint / client-lint
  • GitHub Check: client-check-cyclic-deps / check-cyclic-dependencies
  • GitHub Check: client-build / client-build
  • GitHub Check: client-prettier / prettier-check
🔇 Additional comments (7)
app/client/src/git/ce/constants/messages.tsx (2)

2-2: Capitalization change improves UI consistency.

The change from "RELEASE" to "Release" aligns with proper title case formatting for UI elements. This provides a more polished appearance in the interface.


20-23: Good addition of commit message constants.

Adding these constants for commit information messages promotes maintainability and consistency across the application. The messages are clear and appropriately handle both loading and empty states.

app/client/src/git/components/LatestCommitInfo/LatestCommitInfoView.test.tsx (3)

7-7: Improved test maintainability with dynamic timestamp.

Using a dynamic timestamp based on the current time makes tests more maintainable by avoiding hardcoded dates that could make tests fail if time-based logic changes.


10-28: Good refactor to use test IDs for assertions.

Switching from getByText to getByTestId makes tests more robust against UI text changes. The explicit expectations for each component property provide better test coverage and clearer failure messages.


131-145: Comprehensive test coverage with loading state.

Adding a dedicated test for the loading state ensures the component correctly handles all possible states. This is essential for a good user experience during data fetching.

app/client/src/git/components/ReleaseVersionRadioGroup/ReleaseVersionRadioGroupView.tsx (2)

10-14: Improved API contract with better property naming.

The change from currentVersion to latestReleaseVersion makes the component's purpose clearer. Changing releasedAt from string to number is more appropriate for timestamp handling and calculations.


23-25: Enhanced UX with readable time formatting.

Converting raw timestamps to human-readable format improves user experience by providing context about when releases occurred.

@brayn003 brayn003 merged commit 5a5a0e2 into release Mar 14, 2025
45 checks passed
@brayn003 brayn003 deleted the chore/git-tag-3 branch March 14, 2025 10:18
github-actions bot pushed a commit to Zeral-Zhang/appsmith that referenced this pull request Apr 12, 2025
## Description
- Updates api contracts for pretag validation in release tab

Fixes appsmithorg#38808

## Automation

/ok-to-test tags="@tag.Git"

### 🔍 Cypress test results
<!-- This is an auto-generated comment: Cypress test results  -->
> [!TIP]
> 🟢 🟢 🟢 All cypress tests have passed! 🎉 🎉 🎉
> Workflow run:
<https://github.com/appsmithorg/appsmith/actions/runs/13821575387>
> Commit: 751c6ee
> <a
href="https://internal.appsmith.com/app/cypress-dashboard/rundetails-65890b3c81d7400d08fa9ee5?branch=master&workflowId=13821575387&attempt=1"
target="_blank">Cypress dashboard</a>.
> Tags: `@tag.Git`
> Spec:
> <hr>Wed, 12 Mar 2025 22:04:53 UTC
<!-- end of auto-generated comment: Cypress test results  -->


## Communication
Should the DevRel and Marketing teams inform users about this change?
- [ ] Yes
- [ ] No


<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit

- **New Features**
- Introduced a new `TabRelease` component for managing pre-tagging
functionality.
- Added a custom hook `usePretag` for improved data management related
to pre-tagging.
- Implemented a new `useReleaseTag` hook for handling release tag
creation.
- Enhanced `OpsModalView` to conditionally render tagging capabilities
based on artifact definition.
- Added a new `isGitTaggingEnabled` function to determine if tagging is
applicable based on artifact type.
- Introduced loading states and improved commit information display in
`LatestCommitInfoView`.

- **Bug Fixes**
- Updated components to utilize the new pre-tagging data structure,
ensuring accurate information is displayed.
- Improved display logic in `LatestCommitInfoView` for commit messages
and author information.

- **Refactor**
- Removed outdated commit-related actions and state management,
transitioning to pre-tagging actions and state.
- Modified selectors to focus on pre-tagging data instead of the latest
commit state.
- Renamed and restructured components for clarity and consistency in
handling pre-tagging and release tagging.

- **Style**
  - Updated the `TAB_RELEASE` property for improved display consistency.
- Added new constants for loading and no commit messages to enhance user
feedback.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Git Product Issues related to version control product ok-to-test Required label for CI Packages & Git Pod All issues belonging to Packages and Git skip-changelog Adding this label to a PR prevents it from being listed in the changelog Task A simple Todo

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Task] Git Tagging - View last commit

2 participants